#include "my_string.h"
my_size_t my_strlen(const char *s) {
  if (!s) {
    return 0;
  }
  my_size_t length = 0;
  while (*s++) {
    length++;
  }
  return length;
}
char *my_strncpy(char *dest, const char *src, my_size_t n) {
  while (n-- && *src != '\0') {
    *dest++ = *src++;
  }
  while (n--) {
    *dest++ = '\0';
  }
  return dest;
}
char *my_strncat(char *dest, const char *src, my_size_t n) {
  my_size_t length = my_strlen(dest);
  dest = my_strncpy(dest + length, src, n);
  return dest;
}
int my_strcmp(const char *str1, const char *str2) {
  while (*str1 == *str2) {
    if (*str1 == '\0') {
      return 0;
    }
    str1++, str2++;
  }
  return *str1 - *str2;
}
